package me.leiusual.sharing.api.model

import me.leiusual.sharing.pref.User

/**
 * Create by leiusual on 2018/7/18
 */
class UserInfo {

  data class Response(
      val userId: Long,
      val userIdInClient: Any?,
      val clientId: String,
      val username: String,
      val nickname: String?,
      val realName: String?,
      val birthday: String?,
      val idCard: String?,
      val avatar: String,
      val password: String,
      val email: String?,
      val emailEnabled: Boolean,
      val mobile: String?,
      val mobileEnabled: Boolean,
      val externalCode: String?,
      val introducerCode: String?,
      val starLevel: Int,
      val userType: String,
      val enabled: Boolean,
      val accountNonExpired: Boolean,
      val accountNonLocked: Boolean,
      val credentialsNonExpired: Boolean,
      val tmtAuthorities: List<Any>,
      val authorities: List<Any>
  ) {

    fun replace(user: User) {
      user.userId = userId
      // user.userIdInClient = userIdInClient // 这里一直都是null，使用另一个接口 user/total 获取 userId 字段
      user.clientId = clientId
      user.username = username
      user.nickname = nickname
      user.realName = realName
      user.birthday = birthday
      user.idCard = idCard
      user.avatar = avatar
      user.password = password
      user.email = email
      user.emailEnabled = emailEnabled
      user.mobile = mobile
      user.mobileEnabled = mobileEnabled
      user.externalCode = externalCode
      user.introducerCode = introducerCode
      user.starLevel = starLevel
      user.userType = userType
      user.enabled = enabled
      user.accountNonExpired = accountNonExpired
      user.accountNonLocked = accountNonLocked
      user.credentialsNonExpired = credentialsNonExpired
    }
  }
}